package httpproxymiddleware

import (
	"fmt"
	"go-gateway-learn/dao"
	"go-gateway-learn/middleware"
	"go-gateway-learn/public"

	"github.com/gin-gonic/gin"
)

func HTTPAccessModeMiddleware() gin.HandlerFunc{
	return func(c *gin.Context) {
		service,err :=dao.ServiceManagerHandler.HTTPAccessModel(c)
		if err != nil{
			middleware.ResponseError(c,2000,err)
			c.Abort()
			return
		}
		fmt.Println("matched is : ", public.Obj2Json(service))
		c.Set("service", service)
		c.Next()
	}
}